home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8301 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.6 KB  |  94 lines

  1. Path: news.compuserve.com!newsmaster
  2. From: 76623,2065@compuserve.com  (Bobby Martin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Please please help a newbie!
  5. Date: 16 Feb 1996 17:58:49 GMT
  6. Organization: CompuServe Incorporated
  7. Message-ID: <4g2gkq$10h@dub-news-svc-3.compuserve.com>
  8. References: <4ftoe8$5a2@pacifica.access.ch>
  9. Reply-To: 76623,2065@compuserve.com (Bobby Martin)
  10. NNTP-Posting-Host: hd36-146.compuserve.com
  11. X-Newsreader: IBM NewsReader/2 v1.03
  12.  
  13. It looks as if your code is fine.  You just need to either rename your file with
  14. a .cpp extension or use whatever compiler flag to tell your compiler it is a 
  15. C++ rather than a C file.
  16.  
  17. Hope that helps!
  18. Bobby Martin
  19.  
  20. In <4ftoe8$5a2@pacifica.access.ch>, tombeck@usemail.com (Thomas Beck) writes:
  21. >Hi there!
  22. >
  23. >It's quite embarrassing to ask those two questions, because they seem 
  24. >absolutely stupid (they probably are). Yesterday I started to learn C/C++. I 
  25. >bought a 700 pages book with a cd included that has two compilers on it). I 
  26. >fully understand the chapter about the types, but the things I program just 
  27. >can't be compiled. I extracted the following two problems:
  28. >
  29. >----------- example 1: -------------
  30. >int i;
  31. >int & a=i;
  32. >
  33. >main() {
  34. >}
  35. >--------------------------------------------
  36. >
  37. >This is not compiled, I get the following output with  Symantec C++ 6.11:
  38. >
  39. >D:\SC>sc test1.c        
  40. >
  41. >sccx test1.c
  42. >int & a=i;
  43. >    ^
  44. >test1.c(2) : Error: '=', ';' or ',' expected
  45. >
  46. >--- errorlevel 1
  47. >
  48. >The second thing that doesn't work is this:
  49. >
  50. >----------- example 2: -------------
  51. >struct abc {
  52. >  int i;
  53. >  char a;
  54. >  void f1() {
  55. >  };
  56. >};
  57. >
  58. >main() {
  59. >}
  60. >---------------------------------------------
  61. >
  62. >This isn't compiled either, here's the output:
  63. >
  64. >D:\SC>sc test2.c
  65. >
  66. >sccx test2.c
  67. >  void f1() {
  68. >            ^
  69. >test2.c(4) : Error: illegal type for 'f1' member
  70. >
  71. >--- errorlevel 1
  72. >
  73. >
  74. >Before you think I'm absolutely stupid... I used to be very good at Pascal 
  75. >(TP 6.0), and I'm also experienced in OOP under Pascal. I have no clue of 
  76. >C++, however, and I can only rely on what's written in that book. Apparently 
  77. >it doesn't tell me the truth, does it?
  78. >
  79. >Can you please help me with those two problems (referenced variable and 
  80. >function within a class), so that I can go on and learn a few more difficult 
  81. >things?
  82. >
  83. >Thanks in advance,
  84. >
  85. >Thomas Beck, tombeck@usemail.com
  86. >
  87. >=================================================================
  88. >Summer's day, as she passed away. Birds were singing in the
  89. >summer sky; then came the rain, and once again, a tear fell
  90. >from her mother's eye...
  91. >=================================================================
  92. >
  93.  
  94.